public class Leetcode1732 {
    public int largestAltitude(int[] gain) {
        int maxHeight = 0;
        int height = 0;
        for (int g : gain) {
            height += g;
            if (height > maxHeight) {
                maxHeight = height;

            }
        }
        return maxHeight;
    }
}
